package com.leetcode.partition8;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/20 9:45
 */
public class LC717_1比特与2比特字符 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        int[] bits = new int[ss.length];
        for (int i = 0; i < ss.length; i++) bits[i] = Integer.parseInt(ss[i]);
        writer.write(isOneBitCharacter(bits) + "\n");
        writer.flush();
    }

    public static boolean isOneBitCharacter(int[] bits) {
        int n = bits.length, idx = 0;
        while (idx < n - 1) {
            if (bits[idx] == 1) idx += 2;
            else idx++;
        }
        return idx == n - 1;
    }
}
